package com.ruoyi.shop.systematic.systems.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.common.domain.DtsSystem;
import com.ruoyi.shop.systematic.systems.service.IDtsSystemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统参数管理Controller
 *
 * @author ruoyi
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/systematic/systems")
public class DtsSystemController extends BaseController
{
    @Autowired
    private IDtsSystemService dtsSystemService;

    /**
     * 查询系统参数管理列表
     */
    @PreAuthorize("@ss.hasPermi('systematic:systems:list')")
    @GetMapping("/list")
    public TableDataInfo list(DtsSystem dtsSystem)
    {
        startPage();
        List<DtsSystem> list = dtsSystemService.selectDtsSystemList(dtsSystem);
        return getDataTable(list);
    }

    /**
     * 导出系统参数管理列表
     */
    @PreAuthorize("@ss.hasPermi('systematic:systems:export')")
    @Log(title = "系统参数管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DtsSystem dtsSystem)
    {
        List<DtsSystem> list = dtsSystemService.selectDtsSystemList(dtsSystem);
        ExcelUtil<DtsSystem> util = new ExcelUtil<DtsSystem>(DtsSystem.class);
        util.exportExcel(response, list, "系统参数管理数据");
    }

    /**
     * 获取系统参数管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('systematic:systems:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dtsSystemService.selectDtsSystemById(id));
    }

    /**
     * 新增系统参数管理
     */
    @PreAuthorize("@ss.hasPermi('systematic:systems:add')")
    @Log(title = "系统参数管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DtsSystem dtsSystem)
    {
        return toAjax(dtsSystemService.insertDtsSystem(dtsSystem));
    }

    /**
     * 修改系统参数管理
     */
    @PreAuthorize("@ss.hasPermi('systematic:systems:edit')")
    @Log(title = "系统参数管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DtsSystem dtsSystem)
    {
        return toAjax(dtsSystemService.updateDtsSystem(dtsSystem));
    }

    /**
     * 删除系统参数管理
     */
    @PreAuthorize("@ss.hasPermi('systematic:systems:remove')")
    @Log(title = "系统参数管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dtsSystemService.deleteDtsSystemByIds(ids));
    }
}
